<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/wesite/view/common/base.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>修改手机绑定</title>
    <%@ include file="/wesite/view/common/common.jsp"%>
    <style type="text/css">
        html,body{background:#fff;}
        .loginbox.signbox{
            margin:0;
        }
    </style>
</head>
<body>
<div class="loginbox signbox">
    <div class="login-input" id="page1">
        <div class="input-text"><i class="ico-phone"></i><input name="phone"  type="text"  placeholder="请输入手机号码">
        </div>
        <div class="itemTip" id="itemTip_p"></div>
        <div class="input-text"><i class="ico-code"></i><input class="code" name="oldsmscode" type="text" placeholder="填写短信校验码">
            <span class="send"><a href="javascript:tosendsms();" id="yzmbtn" class="yzm-btn">获取验证码</a></span>
        </div>
        <div class="itemTip2" id="itemTip_old2"></div>
    </div>
    <input type="button" value="下一步" onclick="tonext()">
</div>
</body>
</html>
<script src="${webctx}/script/sms.js"></script>
<script>
    var toast = new auiToast({})
    function tosendsms(){
        if($("[name='phone']").val()==$("[name='uphone']").val()){
            toast.fail({
                title : "请输入新手机号",
                duration : 1000
            })
        }else if(!$w.isMobile($("[name='phone']").val())){
            toast.fail({
                title : "请输入正确手机号",
                duration : 1000
            })
        }else
            sendsms($("[name='phone']").val(),'changephone','yzmbtn');
    }

    function tosendsms(){
        if(!$w.isMobile($("[name='phone']").val())){
            toast.fail({
                title : "请输入正确手机号",
                duration : 1000
            })
        }else
            sendsms($("[name='phone']").val(),'changephone','yzmbtn');
    }

    function tonext() {
        if(!$w.isMobile($("[name='phone']").val())){
            toast.fail({
                title : "请输入正确手机号",
                duration : 1000
            })
        }
        $("#page1 .itemTip").text('');
        $w.httpRequest({
            url:"${ctx}/we/user/checksmscode",
            data:{"mobile":$("[name='phone']").val(),"smscode":$("[name='oldsmscode']").val()},
            ok:function(ret){
                if(ret.Data=='true'){
                    $w.httpRequest({
                        url:"${ctx}/we/user/webindphone",
                        data:{"phone":$("[name='phone']").val(),"smscode":$("[name='oldsmscode']").val()},
                        ok:function(ret){
                            window.location.href="${ctx}/we/user/wehome"
                        },fail:function(ret){
                            toast.fail({
                                title : ret.MsgDesc,
                                duration : 1000
                            })
                            return false;
                        }
                    })
                }else toast.fail({
                    title : "验证码错误或失效",
                    duration : 1000
                })
            }
        })
    }
</script>